function sleep(ms) {
  const now = (new Date()).getTime()
  while((new Date()).getTime() - now < ms) {
    continue
  }
}

Page({
  data: {
    title: 'Welcome To Awesome Words',
    isBig1: false,
    isBig2: false,
    isBig3: false,
    isBig4: false,
    hidden: false
  },
  goHome() {
    this.setData({ hidden: true, isBig1: true})
    sleep(200)
    this.setData({ isBig2: true })
    sleep(200)
    this.setData({ isBig3: true })
    sleep(200)
    this.setData({ isBig4: true })
    sleep(100)
    wx.switchTab({
      url: '/pages/home/index'
    })
  },
  onLoad() {
    let mode = null
    const store = parseInt(wx.getStorageSync('vision-mode'))
    if (isNaN(store)) {
      mode = 1
    } else {
      mode = store
    }
    this.setData({ mode })
  },

  onShow() {
    this.setData({
      isBig1: false,
      isBig2: false,
      isBig3: false,
      isBig4: false,
      hidden: false
    })
  }
});
